<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="Content-Type" content="text/html">
    <meta name="renderer" content="webkit|ie-comp|ie-stand">
    <meta name="viewport" content="initial-scale=1, width=device-width, maximum-scale=1, minimum-scale=1, user-scalable=no">
    <title>会员中心</title>
    <link href="https://cdn.bootcss.com/twitter-bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet">
    <link href="https://at.alicdn.com/t/font_1440001_47llmi4hsil.css" rel="stylesheet">
    <link rel="stylesheet" type="text/css" href="css/globle.css" />
    <link rel="stylesheet" href="css/style.css">
    <link rel="stylesheet" href="css/user.css">
    <link rel="stylesheet" href="css/media.css">
</head>

<body>
    <div id="header"></div>
    <!-- 主体 -->
    <section class="info">
        <div class="container">
            <div class="info-all" id="user-vip">
                <div class="row" id="person">
                    <div class="col-md-10 col-xs-12 tab-content">
                        <div class="tab-pane active" id="info01">
                            <div class="user-content">
                                <div class="support-content-wrap">
                                    <div class="user-content-top">
                                        <div class="user-left">
                                            <div class="avatar">
                                                <img class="user-img" src="https://thirdwx.qlogo.cn/mmopen/xmnzFtMsJYBqNK5e6QpibDXFHl6fYabH8UDdEzVVTnHozH3x2E6zGOics3OeQjOHQxfmOJaoDVe1A5ia3lEs8NWKrNVRJDww0nm/132" alt="">
                                            </div>
                                        </div>
                                        <div class="user-right">
                                            <div class="info01">
                                                <div class="name">
                                                    <div class="left">
                                                        <span>昵称：</span>
                                                        <span style="font-size: 24px;" class="name-id">姿态·</span>
                                                    </div>
                                                </div>
                                                <div class="email">
                                                    <div class="left">
                                                        <span>邮箱：</span>
                                                        <span class="inactive"></span>
                                                    </div>
                                                </div>
                                            </div>
                                        </div>
                                    </div>
                                    <div class="user-content-bot">
                                        <div class="service-plat">
                                            <h4>服务平台</h4>
                                            <ul id="plat-list">
                                                <li>fsafdsf<span class="btn pull-right">删除</span></li>
                                            </ul>
                                        </div>
                                    </div>
                                </div>
                            </div>
                        </div>
                        <!-- 我的评论 -->
                        <div class="tab-pane clearfix" id="myComment">
                            <div class="user-content">
                                <div class="support-content-wrap">
                                    <h4>我的评论</h4>
                                    <ul id="myCommentList">
                                    </ul>
                                </div>
                            </div>
                        </div>
                        <!-- 我的发布 -->
                        <div class="tab-pane" id="info03">
                            <div class="user-content">
                                <div class="support-content-wrap">
                                    <h4>我的发布 <a class="fr c47" href="pushc.html"><em>添加</em></a></h4>
                                    <ul id="getListByUserId">
                                    </ul>
                                </div>
                            </div>
                        </div>
                        <!-- 我的收藏  myCollection-->
                        <div class="tab-pane" id="myCollection">
                            <div class="user-content">
                                <div class="support-content-wrap">
                                    <h4>我的收藏 <a class="fr c47" href="pushc.html"><em>添加</em></a></h4>
                                    <ul id="getMyCollectionList">
                                    </ul>
                                </div>
                            </div>
                        </div>
                        <!-- 我的回复 -->
                        <div class="tab-pane" id="info04">
                            <div class="user-content">
                                <div class="support-content-wrap">
                                    <h4>我的回复</h4>
                                    <ul id="myReplyList">
                                        <li>
                                            <a href="#">
                                                <h5 class="tit">我的回复： <em>2019-05-11 10:11:55</em></h5>
                                                <p class="line">什么资源，直接在视频搜索框里搜索就完事了，输入关键字都是有的，直接按着顺序刷视频也是可以的</p>
                                                <div class="fromecount">
                                                    <p><em>发帖人：小鱼同学</em></p>
                                                    <p>HTML+css后面的小习题有没有素材</p>
                                                </div>
                                            </a>
                                        </li>
                                        <li>
                                            <a href="#">
                                                <h5 class="tit">我的回复：<em>2019-05-11 10:11:55</em></h5>
                                                <p class="line">什么资源，直接在视频搜索框里搜索就完事了，输入关键字都是有的，直接按着顺序刷视频也是可以的</p>
                                                <div class="fromecount">
                                                    <p><em>发帖人：小鱼同学</em></p>
                                                    <p>HTML+css后面的小习题有没有素材</p>
                                                </div>
                                            </a>
                                        </li>
                                        <li>
                                            <a href="#">
                                                <h5 class="tit">我的回复：<em>2019-05-11 10:11:55</em></h5>
                                                <p class="line">什么资源，直接在视频搜索框里搜索就完事了，输入关键字都是有的，直接按着顺序刷视频也是可以的</p>
                                                <div class="fromecount">
                                                    <p><em>发帖人：小鱼同学</em></p>
                                                    <p>HTML+css后面的小习题有没有素材</p>
                                                </div>
                                            </a>
                                        </li>
                                    </ul>
                                </div>
                            </div>
                        </div>
                        <!-- 账户设置 -->
                        <div class="tab-pane" id="userSetting">
                            <div class="user-content">
                                <div class="support-content-wrap">
                                    <form>
                                        <div>
                                            <span>修改头像：</span>
                                            <div style="">
                                                <ul class="upload-ul clearfix">
                                                    <li class="upload-pick">
                                                        <div class="webuploader-container clearfix" id="goodsUpload"></div>
                                                    </li>
                                                    <span class="btn btn-primary" id="btn">上传头像</span>
                                                </ul>
                                            </div>
                                        </div>
                                        <div class="password">修改密码：
                                                <input type="text" class="form-control userPassword">
                                        </div>
                                        <span class="btn btn-primary center-block" id="updata">保存</span>
                                    </form>
                                </div>
                            </div>
                        </div>
                    </div>
                    <div class="col-md-2 col-xs-12">
                        <div class="info-menu">
                            <ul class="nav nav-tabs">
                                <li class="active">
                                    <a href="#info01" aria-controls="info01" role="tab" data-toggle="tab">
                                        <i class="iconfont icon-Userpersonalinform"></i>
                                        我的账户
                                        <i class="glyphicon glyphicon-menu-right hidden-lg hidden-md hidden-sm"></i>
                                    </a>
                                </li>
                                <li>
                                    <a href="#info03" aria-controls="info03" role="tab" data-toggle="tab">
                                        <i class="iconfont icon-dd"></i>
                                        我的发布
                                        <i class="glyphicon glyphicon-menu-right hidden-lg hidden-md hidden-sm"></i>
                                    </a>
                                </li>
                                <li>
                                    <a href="#myCollection" aria-controls="myCollection" role="tab" data-toggle="tab">
                                        <i class="iconfont icon-dd"></i>
                                        我的收藏
                                        <i class="glyphicon glyphicon-menu-right hidden-lg hidden-md hidden-sm"></i>
                                    </a>
                                </li>
                                <li>
                                    <a href="#myComment" aria-controls="myComment" role="tab" data-toggle="tab">
                                        <i class="iconfont icon-gerenxinxi"></i>
                                        我的评论
                                        <i class="glyphicon glyphicon-menu-right hidden-lg hidden-md hidden-sm"></i>
                                    </a>
                                </li>
                                <li>
                                    <a href="#info04" aria-controls="info04" role="tab" data-toggle="tab">
                                        <i class="iconfont icon-fapiao"></i>
                                        我的回复
                                        <i class="glyphicon glyphicon-menu-right hidden-lg hidden-md hidden-sm"></i>
                                    </a>
                                </li>
                                <li>
                                    <a href="#userSetting" role="tab" data-toggle="tab">
                                        <i class="glyphicon glyphicon-cog"></i>
                                        账户设置
                                        <i class="glyphicon glyphicon-menu-right hidden-lg hidden-md hidden-sm"></i>
                                    </a>
                                </li>
                            </ul>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </section>
    <div id="footer"></div>
</body>
<script src="https://cdn.bootcss.com/jquery/3.1.1/jquery.min.js"> </script>
<script src="https://cdn.bootcss.com/twitter-bootstrap/3.3.7/js/bootstrap.min.js"></script>
<script src="js/webuploader.min.js"></script>
<script src="js/diyUpload.js"></script>
<script src="js/md5.js"></script>
<script src="js/core.js"></script>
<script src="js/mine.js"></script>
<script>
$(function() {
    $("#header").load("./header.html")
    $("#footer").load("./footer.html")
    //上传图片
    let userimg = "";
    var $tgaUpload = $('#goodsUpload').diyUpload({
        url: apiurl + 'exchange/attachment/fileUpload',
        success: function(res) {
            console.log(res)
            userimg = res.data;
            console.log(userimg)
        },
        error: function(err) {},
        buttonText: '',
        accept: {
            title: "Images",
            extensions: 'gif,jpg,jpeg,bmp,png'
        },
        thumb: {
            width: 120,
            height: 90,
            quality: 100,
            allowMagnify: true,
            crop: true,
            type: "image/jpeg"
        }
    });
    $("#btn").click(function() { $tgaUpload.upload() });
    $("#updata").click(function(){
        if(userimg == ""){
            alert("请先上传图片！")
            return false;
        }
        let userPassword = $("#userSetting .userPassword").val();
        if(userPassword == ""){
            alert("用户密码不能为空！")
            return false;
        }
        userPassword = hex_md5(userPassword);
        $.ajax({
            url: apiurl + updateUserById,
            type: 'POST',
            dataTyp: "json",
            contentType: "application/json;charset=utf-8",
            data: JSON.stringify({
                "id": userInfo.id,
                "imgUrl": userimg,
                "password": userPassword
            }),
            success: res => {
                if(res.success == true){
                    alert("修改成功！")
                }else{
                    alert("修改失败！")
                }
            },
        })
    })



    if (localStorage.token != null) {
        let userId = JSON.parse(localStorage.user).id;
        let getUserName = JSON.parse(localStorage.username);
        let getPassword = JSON.parse(localStorage.password);
        console.log(userInfo)
        // 用户名
        $(".info01 .name-id").html(userInfo.name) //msg-input
        $(".user-img").attr("src", userInfo.imgUrl);
        $(".info01 .msg-input").val(userInfo.name)
        $(".email .inactive").html(userInfo.email)
        // $(".dataphone").html(userInfo.phone)
        // 渲染服务平台
        let platList = "";
        Getdata(getAgentByUser, { userId: 4 })
            .then(res => {
                console.log(res)
                $.each(res.data, function(index, val) {
                    platList += `<li>${val.name}<span class="btn pull-right" data-id="${index}">删除</span></li>`;
                })
                $("#plat-list").html(platList)
            })
        // 我的发布
        Getdata(getListByUserId, { agentUserId: userId }).then(res => {
            console.log(res.data)
            let itemList = '';
            $.each(res.data, function(index, val) {
                itemList += `<li><a href="detail.html?id=${val.id}"><h5 class="tit">${val.title}</h5>
                                <div class="time"><span>${val.gmtDatetime}</span></div></a>
                            </li>`;
            })
            $("#getListByUserId").html(itemList);
        })
        // 我的收藏 getMyCollectionList
        Getdata(getMyCollectionList, { userType: userType0(), userId: userInfo.id }).then(res => {
            console.log(res)
            let getMyCollectionItem = "";
            $.each(res.data, function(index, val) {
                getMyCollectionItem += `<li><a href="detail.html?id=${val.id}"><h5 class="tit">${val.title}</h5>
                                <div class="time"><span>${val.gmtDatetime}</span></div></a>
                            </li>`
            })
            $("#getMyCollectionList").html(getMyCollectionItem);
        })
        // 我的评论
        Getdata(getMyCommentList, { userId, type: 1 }).then(res => {
            let commentItem = "";
            $.each(res.data, function(index, val) {
                commentItem += `<li><a href="detail.html?id=${val.newsId}">
                                    <p class="content">${val.content}</p><span class="time">${val.gmtDatetime}</span>
                                </a></li>`;
            })
            $("#myCommentList").html(commentItem);
        })
        // 我的回复
        Getdata(getMyCommentList, { userId, type: 2 }).then(res => {
            let myReply = "";
            $.each(res.data, function(index, val) {
                myReply += `<li>
                                            <a href="detail.html?id=${val.newsId}">
                                                <h5 class="tit">我的回复： <em>${val.gmtDatetime}</em></h5>
                                                <p class="line">${val.content}</p>
                                                <div class="fromecount">
                                                    <p><em>发帖人：${val.toName}</em></p>
                                                </div>
                                            </a>
                                        </li>`
            })
            $("#myReplyList").html(myReply);
        })

    } else {
        alert("请先登录！")
        window.location.href = "login.html";
    }
    // 普通会员
})
</script>

</html>